﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DlrBasic.Runtime
{
    /// <summary>
    /// BASIC gosub stack.
    /// </summary>
    public sealed class DlrBasicGosubStack
    {
        Stack<int> states = new Stack<int>();
        const int stackDepth = 1024;

        public int PopState()
        {
            if (states.Count == 0) throw new DlrBasicException(Properties.Resources.ReturnWoGosubException);
            return states.Pop();
        }

        public void PushState(int state)
        {
            if (states.Count >= stackDepth) throw new DlrBasicException(Properties.Resources.StackOverflowException);
            states.Push(state);
        }
    }
}
